/*****************************************************************************
*        描述 :
*             文件描述
*        CLR版本:            3.5
*        创建者 :            蒋 光
*        个人域名:           jiangguang.net.cn
*        命名空间名称:       ECP.Model
*        文件名:             BaseModuleEntity.cs
*        创建系统时间:       2012/11/2 19:07:02
*        创建年份:           2012
*
/*****************************************************************************/

namespace ECP.Model
{
    using System;
    using System.Data;
    using ECP.Utilities;

    [Serializable]
    public class BaseModuleEntity
    {
        private bool allowDelete;
        private bool allowEdit;
        private string code;
        private string createDate;
        private string createUserID;
        private string description;
        private bool enabled;
        private bool expand;
        private string fullName;
        private string id;
        private int imageIndex;
        private bool isGroup;
        private bool isPublic;
        private string modifyDate;
        private string modifyUserID;
        private string navigateUrl;
        private string parentID;
        private int selectedImageIndex;
        private string sortCode;
        private string target;
        private string winForm;

        public BaseModuleEntity()
        {
            this.id = string.Empty;
            this.parentID = string.Empty;
            this.code = string.Empty;
            this.fullName = string.Empty;
            this.navigateUrl = string.Empty;
            this.winForm = string.Empty;
            this.target = string.Empty;
            this.isGroup = true;
            this.isPublic = true;
            this.expand = true;
            this.enabled = true;
            this.allowEdit = true;
            this.allowDelete = true;
            this.description = string.Empty;
            this.sortCode = string.Empty;
            this.createUserID = string.Empty;
            this.createDate = string.Empty;
            this.modifyUserID = string.Empty;
            this.modifyDate = string.Empty;
        }

        public BaseModuleEntity(DataRow dataRow)
        {
            this.id = string.Empty;
            this.parentID = string.Empty;
            this.code = string.Empty;
            this.fullName = string.Empty;
            this.navigateUrl = string.Empty;
            this.winForm = string.Empty;
            this.target = string.Empty;
            this.isGroup = true;
            this.isPublic = true;
            this.expand = true;
            this.enabled = true;
            this.allowEdit = true;
            this.allowDelete = true;
            this.description = string.Empty;
            this.sortCode = string.Empty;
            this.createUserID = string.Empty;
            this.createDate = string.Empty;
            this.modifyUserID = string.Empty;
            this.modifyDate = string.Empty;
            this.GetFrom(dataRow);
        }

        public BaseModuleEntity(DataTable dataTable)
        {
            this.id = string.Empty;
            this.parentID = string.Empty;
            this.code = string.Empty;
            this.fullName = string.Empty;
            this.navigateUrl = string.Empty;
            this.winForm = string.Empty;
            this.target = string.Empty;
            this.isGroup = true;
            this.isPublic = true;
            this.expand = true;
            this.enabled = true;
            this.allowEdit = true;
            this.allowDelete = true;
            this.description = string.Empty;
            this.sortCode = string.Empty;
            this.createUserID = string.Empty;
            this.createDate = string.Empty;
            this.modifyUserID = string.Empty;
            this.modifyDate = string.Empty;
            this.GetFrom(dataTable);
        }

        public void ClearProperty()
        {
            this.NavigateUrl = string.Empty;
            this.WinForm = string.Empty;
            this.Target = string.Empty;
            this.IsGroup = false;
            this.IsPublic = false;
            this.Expand = false;
        }

        public BaseModuleEntity GetFrom(DataRow dataRow)
        {
            this.ID = BaseBusinessLogic.ConvertToString(dataRow[BaseModuleTable.FieldID]);
            this.ParentID = BaseBusinessLogic.ConvertToString(dataRow[BaseModuleTable.FieldParentID]);
            this.Code = BaseBusinessLogic.ConvertToString(dataRow[BaseModuleTable.FieldCode]);
            this.FullName = BaseBusinessLogic.ConvertToString(dataRow[BaseModuleTable.FieldFullName]);
            this.NavigateUrl = BaseBusinessLogic.ConvertToString(dataRow[BaseModuleTable.FieldNavigateUrl]);
            this.WinForm = BaseBusinessLogic.ConvertToString(dataRow[BaseModuleTable.FieldWinForm]);
            this.Target = BaseBusinessLogic.ConvertToString(dataRow[BaseModuleTable.FieldTarget]);
            this.SortCode = BaseBusinessLogic.ConvertToString(dataRow[BaseModuleTable.FieldSortCode]);
            this.Description = BaseBusinessLogic.ConvertToString(dataRow[BaseModuleTable.FieldDescription]);
            this.IsGroup = BaseBusinessLogic.ConvertIntToBoolean(dataRow[BaseModuleTable.FieldIsGroup]);
            this.IsPublic = BaseBusinessLogic.ConvertIntToBoolean(dataRow[BaseModuleTable.FieldIsPublic]);
            this.Enabled = BaseBusinessLogic.ConvertIntToBoolean(dataRow[BaseModuleTable.FieldEnabled]);
            this.AllowEdit = BaseBusinessLogic.ConvertIntToBoolean(dataRow[BaseModuleTable.FieldAllowEdit]);
            this.AllowDelete = BaseBusinessLogic.ConvertIntToBoolean(dataRow[BaseModuleTable.FieldAllowDelete]);
            this.Expand = BaseBusinessLogic.ConvertIntToBoolean(dataRow[BaseModuleTable.FieldExpand]);
            this.CreateUserID = BaseBusinessLogic.ConvertToString(dataRow[BaseModuleTable.FieldCreateUserID]);
            this.CreateDate = BaseBusinessLogic.ConvertToString(dataRow[BaseModuleTable.FieldCreateDate]);
            this.ModifyUserID = BaseBusinessLogic.ConvertToString(dataRow[BaseModuleTable.FieldModifyUserID]);
            this.ModifyDate = BaseBusinessLogic.ConvertToString(dataRow[BaseModuleTable.FieldModifyDate]);
            return this;
        }

        public BaseModuleEntity GetFrom(DataTable dataTable)
        {
            foreach (DataRow row in dataTable.Rows)
            {
                this.GetFrom(row);
                break;
            }
            return this;
        }

        public bool AllowDelete
        {
            get
            {
                return this.allowDelete;
            }
            set
            {
                this.allowDelete = value;
            }
        }

        public bool AllowEdit
        {
            get
            {
                return this.allowEdit;
            }
            set
            {
                this.allowEdit = value;
            }
        }

        public string Code
        {
            get
            {
                return this.code;
            }
            set
            {
                this.code = value;
            }
        }

        public string CreateDate
        {
            get
            {
                return this.createDate;
            }
            set
            {
                this.createDate = value;
            }
        }

        public string CreateUserID
        {
            get
            {
                return this.createUserID;
            }
            set
            {
                this.createUserID = value;
            }
        }

        public string Description
        {
            get
            {
                return this.description;
            }
            set
            {
                this.description = value;
            }
        }

        public bool Enabled
        {
            get
            {
                return this.enabled;
            }
            set
            {
                this.enabled = value;
            }
        }

        public bool Expand
        {
            get
            {
                return this.expand;
            }
            set
            {
                this.expand = value;
            }
        }

        public string FullName
        {
            get
            {
                return this.fullName;
            }
            set
            {
                this.fullName = value;
            }
        }

        public string ID
        {
            get
            {
                return this.id;
            }
            set
            {
                this.id = value;
            }
        }

        public int ImageIndex
        {
            get
            {
                return this.imageIndex;
            }
            set
            {
                this.imageIndex = value;
            }
        }

        public bool IsGroup
        {
            get
            {
                return this.isGroup;
            }
            set
            {
                this.isGroup = value;
            }
        }

        public bool IsPublic
        {
            get
            {
                return this.isPublic;
            }
            set
            {
                this.isPublic = value;
            }
        }

        public string ModifyDate
        {
            get
            {
                return this.modifyDate;
            }
            set
            {
                this.modifyDate = value;
            }
        }

        public string ModifyUserID
        {
            get
            {
                return this.modifyUserID;
            }
            set
            {
                this.modifyUserID = value;
            }
        }

        public string NavigateUrl
        {
            get
            {
                return this.navigateUrl;
            }
            set
            {
                this.navigateUrl = value;
            }
        }

        public string ParentID
        {
            get
            {
                return this.parentID;
            }
            set
            {
                this.parentID = value;
            }
        }

        public int SelectedImageIndex
        {
            get
            {
                return this.selectedImageIndex;
            }
            set
            {
                this.selectedImageIndex = value;
            }
        }

        public string SortCode
        {
            get
            {
                return this.sortCode;
            }
            set
            {
                this.sortCode = value;
            }
        }

        public string Target
        {
            get
            {
                return this.target;
            }
            set
            {
                this.target = value;
            }
        }

        public string WinForm
        {
            get
            {
                return this.winForm;
            }
            set
            {
                this.winForm = value;
            }
        }
    }
}